import urllib.request
# 使用urllib获取百度首页源码
url = 'http://www.baidu.com'

# 模拟浏览器发送请求
resp = urllib.request.urlopen(url)
print(resp)
context = resp.read().decode("utf-8")
print(context)
